package com.qf.controller;

import com.qf.entity.SetMeal;
import com.qf.entity.custom.SetMealCustom;
import com.qf.service.SetMealCustomService;
import com.qf.tools.ResponseUtils;
import com.qf.tools.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description TODO
 * @Author 刘珈玮
 * @Date 2020/7/25 10:35
 */
@RestController
@RequestMapping("/setMealCustomController")
public class SetMealCustomController {
    @Autowired
    private SetMealCustomService setMealCustomService;

    /**
     * 套餐内容接口：根据套餐id查询套餐信息
     * @param setMeal 套餐id
     * @return 返回ResultEntity类型的成功或者失败信息
     */
    @RequestMapping(value = "/getSetMealProduct", method = RequestMethod.POST)
    public ResultEntity getSetMealProduct(@RequestBody SetMeal setMeal) {
        if (setMeal != null) {
            Integer setMealId = setMeal.getSetMealId();
            List<SetMealCustom> setMealProduct = setMealCustomService.getSetMealProduct(setMealId);
            if (setMealProduct != null) {
                return ResultEntity.success(setMealProduct);
            } else {
                return ResponseUtils.responseClinet(false);
            }
        } else {
            return ResponseUtils.responseClinet(false);
        }
    }
}
